package com.broheim.websocket.core.endpoint;

import com.broheim.websocket.core.listener.Listener;
import lombok.Getter;
import lombok.Setter;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

@Getter
@Setter
public abstract class EndpointConfig {

    protected static Map<String, List<Listener>> urlListener = new ConcurrentHashMap<String, List<Listener>>();

    public static void registerListener(String path, Listener listener) {
        List<Listener> listeners = urlListener.get(path);
        if (null == listeners) {
            listeners = new ArrayList<>();
            urlListener.put(path, listeners);
        }
        listeners.add(listener);
    }

}
